package com.zs.zcerp.approval.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zs.zcerp.approval.entity.QhBasestdMEntity;
import com.zs.zcerp.approval.entity.QhBillstdD;
import com.zs.zcerp.approval.entity.QhbillstdmEntity;
import com.zs.zcerp.approval.mapper.QhbillstddMapper;
import com.zs.zcerp.approval.mapper.QhbillstdmMapper;
import com.zs.zcerp.approval.service.IQhbillstddService;
import com.zs.zcerp.approval.service.IQhbillstdmService;
import com.zs.zcerp.common.entity.FebsConstant;
import com.zs.zcerp.common.entity.QueryRequest;
import com.zs.zcerp.common.utils.SortUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.List;

/**
 * Henry
 */

@Service
@RequiredArgsConstructor
@DS("oracle") //从oracle库数据查询
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public class QhbillstddServiceImpl extends ServiceImpl<QhbillstddMapper, QhBillstdD> implements IQhbillstddService {



        @Override
    @Transactional(rollbackFor = Exception.class)
    public void createBase(QhBillstdD qhBillstdD) {
            qhBillstdD.setLastDate(new Date());

        save(qhBillstdD);

    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deleteBybillstdG(String[] basestdNos) {
        List<String> list = Arrays.asList(basestdNos);
        baseMapper.delete(new QueryWrapper<QhBillstdD>().lambda().in(QhBillstdD::getBillstdG, list));
    }

    @Override
    public List<QhBillstdD> findBillstdList(QhBasestdMEntity qhBasestdmEntity) {
        return  baseMapper.findBillstdList(qhBasestdmEntity);
    }

    @Override
    public List<QhBillstdD> findBillstdGList(QhBasestdMEntity qhBasestdmEntity) {
        return  baseMapper.findBillstdGList(qhBasestdmEntity);
    }

    @Override
    public List<QhBillstdD> findEmpNoAndDeptNameList(String name) {
        return  baseMapper.findEmpNoAndDeptNameList(name);
    }

    @Override
    public void deleteBillstddByBasestdNo(String[] basestdNos) {
        List<String> list = Arrays.asList(basestdNos);
        baseMapper.delete(new QueryWrapper<QhBillstdD>().lambda().in(QhBillstdD::getBasestdNo, list));
    }


}
